package com.example.oauth2demo.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpSession;

/**
 * @author karidyang
 * @since 1.0.0
 * Date: 2021-04-19
 **/
@Controller
public class IndexController {
    @Autowired
    private TestCacheService testCacheService;

    @GetMapping("/")
    public String index(HttpSession session, Model model) {
        System.out.println(testCacheService.buildTestString());
        model.addAttribute("user", session.getAttribute("user"));
        model.addAttribute("avatar_url", session.getAttribute("avatar_url"));
        return "index";
    }

    @GetMapping("/about")
    public String about(HttpSession session, Model model) {

        model.addAttribute("user", session.getAttribute("user"));
        model.addAttribute("avatar_url", session.getAttribute("avatar_url"));
        return "about";
    }

    @GetMapping("/foo")
    public String foo() {

        return "foo";
    }
}
